#include <SLES/OpenSLES.h>

#include <stdio.h>
#include <assert.h>

static SLObjectItf engineObject = NULL;
static SLEngineItf engineEngine;

static SLAudioIODeviceCapabilitiesItf caps;

int main(int argc, char *argv[])
{
	SLresult result;
	
	result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
	assert(SL_RESULT_SUCCESS == result);
	result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);	
	assert(SL_RESULT_SUCCESS == result);
	result = (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
	printf("engineEngine=%08x\n", engineEngine);
	assert(SL_RESULT_SUCCESS == result);
	result = (*engineObject)->GetInterface(engineObject, SL_IID_AUDIOIODEVICECAPABILITIES, &caps);
	assert(SL_RESULT_SUCCESS == result);
	printf("caps=%08x\n", caps);
	SLint32 num;
	SLuint32 ids[128];
	result = (*caps)->GetAvailableAudioOutputs(caps, &num, ids);
	assert(SL_RESULT_SUCCESS == result);
	printf("num = %d\n", num);
	SLAudioOutputDescriptor out_desc;
	for( int i = 0; i < num; i ++ ){
		(*caps)->QueryAudioOutputCapabilities(caps, ids[i], &out_desc);
		printf("Device %s:\n", out_desc.pDeviceName);
	}
	return 0;
}
